var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(e, d, c) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = c;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            im.dispose();
            var f = im.getItemId();
            im.gainItem(f, -1);
            var b = im.rand(1, 10000);
            if (b < 4) {
                im.gainItem(2439301, 5)
            } else {
                if (b < 20) {
                    im.gainItem(2437760, 10)
                } else {
                    if (b < 100) {
                        im.gainItem(2437760, 2)
                    } else {
                        if (b < 1000) {
                            im.gainItem(2437760, 1)
                        } else {
                            if (b < 5500) {
                                im.gainItem(2437880, 1)
                            } else {
                                im.gainItem(2437750, 1)
                            }
                        }
                    }
                }
            }
        }
    }
};